
function createBrowser(url, fn) {
	var browser = new ActiveXObject("InternetExplorer.Application");
	browser.visible = true;
	browser.navigate(url);
	var waitor = function() {
		if (browser.busy) {
			setTimeout(arguments.callee, 100);
		} else {
			fn(browser, browser.document, browser.document.parentWindow);
		}
	}
	waitor();
}

function main() {
	
	createBrowser("http://www.baidu.com", function(browser, document, w) {
		alert("wait")
		w.execScript("window.location.href = \"http://www.sina.com.cn\"");
	});
}

//
//debugger;
//var ws = new ActiveXObject("InternetExplorer.Application");
//ws.visible = true;
//ws.navigate("https://dynamic.12306.cn/otsweb/");
//
//while (ws.busy) {
//	WScript.Sleep(100);
//}
//ws.document.parentWindow.execScript("document._parentWindow = window;", "Javascript");
//
//var iframe = ws.document.getElementById("main");
//var window = iframe.contentWindow;
//var document = window.document;
//var $ = window.$;
//
//
//
//function login() {
//	var name = "koffighter";
//	var password = "caodaniu";
//
//	$("#UserName").val(name);
//	$("#password").val(password);
//	window.checkAysnSuggest();
//}
//
//login();

